package com.jk.springbootes.service;

import com.jk.springbootes.dao.TestDao;
import com.jk.springbootes.entity.TestEntity;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author 赵优秀
 * @version 1.0.0
 * @ClassName TestService.java
 * @Description TODO
 * @createTime 2021年08月29日 19:33:00
 */
@Service
public class TestService {
  @Autowired
    private TestDao testDao;

    public List<TestEntity> findTest() {
        Iterable<TestEntity> all = testDao.findAll();
        Iterator<TestEntity> iterator = all.iterator();
        List<TestEntity> list=new ArrayList<>();
        while (iterator.hasNext()){
            list.add(iterator.next());
        }
        return list;
    }
//新增
    public void add(TestEntity entity) {
        testDao.save(entity);
    }
}
